{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, TypeFamilies #-}

module Survey.DENIS
 ( DENIS(..)
 , IJK
 ) where

import Survey
import ObsData (ObsData(..) )
import Model.Photometry (ModelPhotometry(..))

import Data.AdditiveGroup (AdditiveGroup(..))
--import Data.VectorSpace   (VectorSpace(..), InnerSpace, (<.>))

-- Обзор
data DENIS = DENIS deriving Show

-- DENIS
instance ModelPhotometry (IJ DENIS) where
  mag = return $ const $  IJ DENIS $ Just 1

instance ModelPhotometry (IK DENIS) where
  mag = return $ const $ IK DENIS $ Just 1


-- IJK обзора DENIS
type IJK = (I DENIS, J DENIS, K DENIS)

instance ObsData IJK where
  type Data IJK = (IJ DENIS, IK DENIS)

  toInitalData (I DENIS i, J DENIS j, K DENIS k) = return (IJ DENIS (i-j), (IK DENIS (i-k)))
   
  toModelData _ = mag

-- Standard instance for an applicative functor applied to a vector space.
instance  AdditiveGroup (IJ DENIS) where
  zeroV = IJ DENIS $ Nothing 
  (^+^) (IJ _ a) (IJ _ b)  = IJ DENIS $ a+b
  negateV (IJ _ a) = IJ DENIS (-a)

instance  AdditiveGroup (IK DENIS) where
  zeroV = IK DENIS $ Nothing 
  (^+^) (IK _ a) (IK _ b)  = IK DENIS $ a+b
  negateV (IK _ a) = IK DENIS (-a)

